package f3a.bancohoraswidget;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import f3a.bancohoras.R;

import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.widget.RemoteViews;

public class BancoHorasWidget extends  AppWidgetProvider{

	private RemoteViews remoteViews;
	private DateFormat format;
	
	@Override
	public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
		// TODO Auto-generated method stub
//		super.onUpdate(context, appWidgetManager, appWidgetIds);
		RemoteViews remoteViews;
		ComponentName bancoHorasWidget;
		format = SimpleDateFormat.getTimeInstance(SimpleDateFormat.MEDIUM,Locale.getDefault());
		
		remoteViews = new RemoteViews(context.getPackageName(),R.layout.main);
		bancoHorasWidget = new ComponentName(context,BancoHorasWidget.class);
		remoteViews.setTextViewText(R.id.widget_TextView, "Time = " + format.format(new Date()));
		appWidgetManager.updateAppWidget( bancoHorasWidget, remoteViews );
		
	}
	
	public void setWidgetText(){
		remoteViews.setTextViewText(R.id.widget_TextView, "Time = " + format.format(new Date()));
		
	}
	
	

}
